# -*- coding: utf-8 -*-
"""
Created on Wed Apr 17 10:13:19 2024

@author: 刘翼
"""

import cv2
import numpy as np

img = cv2.imread(r"C:\Users\Public\opencv\Figure\bird.jpg")
B,G,R = cv2.split(img)
 
#通道扩展
zeros = np.zeros(img.shape[:2], np.uint8)
img_B = cv2.merge([B, zeros, zeros])
img_G = cv2.merge([zeros, G, zeros])
img_R = cv2.merge([zeros, zeros, R])

cv2.imshow("BGR_img", img)
cv2.imshow("B_img", img_B)
cv2.imshow("G_img", img_G)
cv2.imshow("R_img", img_R)


merged = cv2.merge([B,G,R])  #合并通道
cv2.imshow("merged image", merged)

cv2.waitKey(0)
cv2.destroyAllWindows()